LGF_MeasureCpuLoad (FB / 1.1.1)

Overview

Author: Simatic Systems Support

Short description

Measurement and calculation of PLC CPU load for different OB types

Block Interface

LGF_MeasureCpuLoad (FB)
Bool  enable valid  Bool
    
Bool  reset busy  Bool
    
Real  loadCascade error  Bool
    
LGF_typeMeasureCpuLoad_Configuration  configuration status  Word
    
   averagingActive  Bool
    
   loadCascadeActive  Bool
    
   cycleTimeMin  LTime
    
   cycleTimeActual  LTime
    
   cycleTimeMax  LTime
    
   cycleTimeMaxConfigured  LTime
    
   runtime  LReal
    
   cpuLoad  Real
    
   comLoad  Real
    
   comLoadConfigured  Real
    
   limitWarning  Bool
    
   limitAlarm  Bool
    
   resultsCyclic  Array[0..#LAST_CYCLIC_BLOCK_INDEX] of LGF_typeMeasureCpuLoad_ResultBlock
    
   results  Array[0..#LAST_BLOCK_INDEX] of LGF_typeMeasureCpuLoad_ResultBlock
    
   diagnostics  LGF_typeDiagnostics
    
   

Input parameter

IdentifierData type Default value Description
enableBool FALSE TRUE: Enable functionality of FB
resetBool FALSE Rising edge: Reset all internal values and as well PLC CPU timing statistic
loadCascadeReal 0.0 Percentage Load Value from another `LGF_MeasureCpuLoad` [%] (Connect `cpuLoad` from predecessor instance call)
configurationLGF_typeMeasureCpuLoad_Configuration --- This UDT belongs to the Module `LGF_MeasureCpuLoad` and lists all possible parameter to configure its behavior.

Output parameter

IdentifierData type Description
validBool TRUE: Valid set of output values available at the FB
busyBool TRUE: FB is not finished, and new output values can be expected
errorBool TRUE: An error occurred during the execution of the FB
statusWord 16#0000 - 16#7FFF: Status of the FB, 16#8000 - 16#FFFF: Error identification
averagingActiveBool TRUE: Averaging of actual values active
loadCascadeActiveBool TRUE: Load calculation cascade active
cycleTimeMinLTime Minimum cycle time [ms]
cycleTimeActualLTime Actual cycle time [ms]
cycleTimeMaxLTime Maximum cycle time [ms]
cycleTimeMaxConfiguredLTime Configured maximum cycle time [ms] (in plc hardware configuration)
runtimeLReal Actual cycle time incl. interrupts [ms]
cpuLoadReal Actual PLC CPU load [%]
comLoadReal Actual communication load [%]
comLoadConfiguredReal Configured communication load [%]
limitWarningBool Load more than configured threshold value 'configuration.limitWarning'
limitAlarmBool Load more than configured threshold value 'configuration.limitAlarm'
resultsCyclicArray[0..#LAST_CYCLIC_BLOCK_INDEX] of LGF_typeMeasureCpuLoad_ResultBlock Results of Cyclic OB read outs
resultsArray[0..#LAST_BLOCK_INDEX] of LGF_typeMeasureCpuLoad_ResultBlock Results of NON-Cyclic OB read outs
diagnosticsLGF_typeDiagnostics Diagnostic structure to store and transfer diagnostic information from blocks through the interface.

Status & Error codes

Code / ValueIdentifier / Description
16#7000STATUS_NO_CALL
No job being currently processed
16#7001STATUS_FIRST_CALL
First call after incoming new job (rising edge 'enable')
16#7002STATUS_SUBSEQUENT_CALL
Subsequent call during active processing without further details
16#8600ERR_UNDEFINED_STATE
Error: Due to an undefined state in state machine
16#8601ERROR_RTINFO_CONFIGURED_MAX_CYCLETIME
Error: RT INFO read configured MAX cycle time Information
16#8602ERROR_RTINFO_CONFIGURED_COM_LOAD
Error: RT INFO read configured COM Load Information
16#8610ERROR_RTINFO_ACTUAL_CYCLETIME
Error: RT INFO read actual cycle time Information
16#8611ERROR_RTINFO_ACTUAL_MIN_CYCLETIME
Error: RT INFO read MIN cycle time Information
16#8612ERROR_RTINFO_ACTUAL_MAX_CYCLETIME
Error: RT INFO read MAX cycle time Information
16#8620ERROR_RTINFO_ACTUAL_COM_LOAD
Error: RT INFO read actual COM Load Information
16#8630ERROR_RTINFO_RESET_STATISTICS
Error: RT INFO reset statistic information
16#9000ERROR_RTINFO_RUNTIME_OB_CYCLIC
Error: Read RT INFO cycle time Information OB + index of OB in array
16#9100ERROR_RTINFO_RUNTIME_OB
Error: Read RT INFO cycle time Information OB + index of OB in array

User defined datatype(s)

LGF_typeMeasureCpuLoad_Configuration (UDT / V1.0.0)

This UDT belongs to the Module LGF_MeasureCpuLoad and lists all possible parameter to configure its behavior.

Identifier Data type Default value Description
cfcRun Bool FALSE CFC Run (OB No is shifted to 10xx)
averagingValues USInt 0 Averaging the measured values by building the arithmetic average value
comLoadSim UInt 0 Com Load Simulation [%]
IF > 0.0 used as value for calculation
IF <= 0.0 take real com load value read from PLC
limitWarning Real 70.0 Warning threshold value [%]
limitAlarm Real 100.0 Alarming threshold value [%]
organizationBlocksCyclic Array[0..10] of LGF_typeMeasureCpuLoad_ConfigurationBlock --- Cyclic Blocks to measure
organizationBlocks Array[0..30] of LGF_typeMeasureCpuLoad_ConfigurationBlock --- NON-Cyclic Blocks to measure

LGF_typeMeasureCpuLoad_ConfigurationBlock (UDT / V1.0.0)

Configuration for the block to be measured

Identifier Data type Default value Description
enableMeasurement Bool FALSE Enable measurement
obNumber Int 0 Organization's Block Number of the module to be measured
initialLoad Real 0.0 Initial load [%], only used if averaging is turned on

LGF_typeMeasureCpuLoad_ResultBlock (UDT / V1.0.0)

Results for Block measured

Identifier Data type Default value Description
obNumber Int 0 Organisation Block Number
runtime LTime --- Runtime of Organization block [ms]
cycleLoad Real 0.0 Load of block calculated using the cycle time [%]
maxCycleLoad Real 0.0 Load of block calculated using the MAX cycle time [%]
error Bool FALSE TRUE: An error occurred during reading block statistic
status Word 16#0000 16#0000 - 16#7FFF: Status of the `RT_INFO`, 16#8000 - 16#FFFF: Error identification

LGF_typeDiagnostics (UDT / V1.0.1)

Diagnostic structure to store and transfer diagnostic information from blocks through the interface.

Identifier Data type Default value Description
status Word 16#0000 Status of the Block or error identification when error occurred
subfunctionStatus Word 16#0000 Status or return value of called FB's, FC's and system blocks
stateNumber DInt 0 State in the state machine of the block where the error occurred

Functional description

This function can be used to read out the various runtimes of organizational blocks (OB) and calculate the PLC CPU load based on the results.

The OBs to be considered are specified and activated in the configuration; please note that cyclical and acyclically OBs must be configured in separate structures.

It is also possible to

Change log

Version & DateChange description
1.0.0SAG BG
19.05.2024First Release
1.1.0SAG BG
06.05.2024Add Output with overall runtime incl. interrupts
1.1.1Siemens System Support
03.09.2025Bugfixed error in loop